{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/peremartra/Large-Language-Model-Notebooks-Course/blob/main/4-Evaluating%20LLMs/langsmith_Medical_Assistant_Agent.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "<div align=\"center\">\n",
        "<h1><a href=\"https://github.com/peremartra/Large-Language-Model-Notebooks-Course\">Learn by Doing LLM Projects</a></h1>\n",
        "    <h3>Understand And Apply Large Language Models</h3>\n",
        "    <h2>Tracing a Medical Assistant RAG System chat with LangSmith</h2>\n",
        "    \n",
        "</div>\n",
        "\n",
        "<div align=\"center\">\n",
        "  by <b>Pere Martra</b>\n",
        "  <a target=\"_blank\" href=\"https://www.linkedin.com/in/pere-martra/\"><img src=\"https://img.shields.io/badge/style--5eba00.svg?label=LinkedIn&logo=linkedin&style=social\"></a>  \n",
        "</div>\n",
        "\n",
        "<div align=\"center\">\n",
        "<a target=\"_blank\" href=\"https://www.langchain.com/langsmith\"><img src=\"https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/langsmith.png?raw=true\"></a>  \n",
        "</div>"
      ],
      "metadata": {
        "id": "f3cvnSVemTSU"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "In this notebook, we will explore how to trace the different calls that occur in a LangChain Agent using LangSmith. We will use a familiar agent, employed in the LangChain section of the course, where a RAG system with medical information was created.\n",
        "\n",
        "So, not only will we observe the traces of the agent, but we will also examine the traces of the retriever. Additionally, we'll inspect the query sent to the vectorial database and the returned results.\n",
        "__________"
      ],
      "metadata": {
        "id": "knN-MUbEIMI8"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "#Installing libraries & Loading Dataset"
      ],
      "metadata": {
        "id": "KNW-LniD2I2o"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "id": "pva9ehKXUpU2",
        "outputId": "1e73d6c5-c16b-4379-a35a-c78fe046c86d",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m803.6/803.6 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.9/1.9 MB\u001b[0m \u001b[31m11.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m276.8/276.8 kB\u001b[0m \u001b[31m10.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.5/56.5 kB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.4/49.4 kB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.9/1.9 MB\u001b[0m \u001b[31m16.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m21.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m23.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m28.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m25.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m21.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m24.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m22.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m25.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m26.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m24.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m276.6/276.6 kB\u001b[0m \u001b[31m21.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m279.2/279.2 kB\u001b[0m \u001b[31m22.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m274.6/274.6 kB\u001b[0m \u001b[31m19.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m273.9/273.9 kB\u001b[0m \u001b[31m21.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m273.0/273.0 kB\u001b[0m \u001b[31m22.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m271.6/271.6 kB\u001b[0m \u001b[31m20.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m269.1/269.1 kB\u001b[0m \u001b[31m15.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m260.9/260.9 kB\u001b[0m \u001b[31m19.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m258.8/258.8 kB\u001b[0m \u001b[31m20.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m256.9/256.9 kB\u001b[0m \u001b[31m21.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m252.6/252.6 kB\u001b[0m \u001b[31m21.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m252.4/252.4 kB\u001b[0m \u001b[31m17.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m250.8/250.8 kB\u001b[0m \u001b[31m20.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m246.4/246.4 kB\u001b[0m \u001b[31m18.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m242.1/242.1 kB\u001b[0m \u001b[31m21.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m241.3/241.3 kB\u001b[0m \u001b[31m17.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m241.2/241.2 kB\u001b[0m \u001b[31m20.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.4/55.4 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.0/53.0 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m267.1/267.1 kB\u001b[0m \u001b[31m7.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m42.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.6/75.6 kB\u001b[0m \u001b[31m7.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m507.1/507.1 kB\u001b[0m \u001b[31m6.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m115.3/115.3 kB\u001b[0m \u001b[31m10.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m194.1/194.1 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.8/134.8 kB\u001b[0m \u001b[31m12.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.8/134.8 kB\u001b[0m \u001b[31m11.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m509.0/509.0 kB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.4/2.4 MB\u001b[0m \u001b[31m12.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m91.9/91.9 kB\u001b[0m \u001b[31m10.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.8/60.8 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.3/41.3 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.4/5.4 MB\u001b[0m \u001b[31m22.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.8/6.8 MB\u001b[0m \u001b[31m37.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.1/60.1 kB\u001b[0m \u001b[31m6.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m106.1/106.1 kB\u001b[0m \u001b[31m10.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.3/67.3 kB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h  Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
            "  Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
            "  Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m698.9/698.9 kB\u001b[0m \u001b[31m38.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.6/1.6 MB\u001b[0m \u001b[31m42.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.6/67.6 kB\u001b[0m \u001b[31m6.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.9/71.9 kB\u001b[0m \u001b[31m7.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.8/50.8 kB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m341.4/341.4 kB\u001b[0m \u001b[31m29.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m50.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m44.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m12.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h  Building wheel for pypika (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n"
          ]
        }
      ],
      "source": [
        "!pip install -q langchain==0.1.4\n",
        "!pip install -q langchain-openai==0.0.5\n",
        "!pip install -q langchainhub==0.1.14\n",
        "!pip install -q datasets==2.16.1\n",
        "!pip install -q chromadb==0.4.22"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We will download the dataset from the Hugging Face datasets library. It's a dataset with information about diseases."
      ],
      "metadata": {
        "id": "KEwdHiGFkK_S"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "id": "laSDMjqQXuj-",
        "outputId": "358c040f-22c3-4088-f060-5342dc8d1229",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 237,
          "referenced_widgets": [
            "a2c808c03cce4c2bbc9d467b8d519e64",
            "748378a5112f4762a1369cca9d77cf20",
            "4361d59ef82f43ca90184953d81edccb",
            "efb885302da14b20bc2d0477c839eeea",
            "b19d4fcd66874a2294c70ac0d7e39886",
            "38a7b565d9cb4ef0b919656e38ff5aff",
            "03be5a89a311430cab159456967206f9",
            "b871473561b94294b833a7a9018f0e0e",
            "9ffcd6a598a04af1916ed206b7e7ad9d",
            "76f88769f6de400ebbc61fbd902900aa",
            "79220cfaa4f8446e968bf27f5100b8a5",
            "f7dc8c26fe89414a9270796103d46fa8",
            "3e72acf13fd94e14bafcfd59e66a94f0",
            "36bc7364f6094102b8c9c03ea183fb7d",
            "8d243a889a484d43b46ef166987461b1",
            "7b44788fa5ca429faa283b1a2cd2a194",
            "8c9d6fe25d2c4a00a4ca561c8568abc0",
            "1b1c33a2a5a348a98fd06644a4d5cb28",
            "869ed7f3b5e94da29bd8e78b92bcf2e8",
            "4bdea684772845cfb4a865f291014895",
            "10bf5a0da37b4a58916fa88b30fef35e",
            "3828bb2edc5648e1b05077c6b908f025",
            "9d19a2d081bd436c811acbc6c7eb7987",
            "7063a9f5b96e4f59b5510f0f05486587",
            "017948bf45934498b33caa4854db2836",
            "e932d3d124184cc7b94f2a2da1ac1920",
            "d409bfdff1de4947b9ede61d37d9f08e",
            "a951c64095ff4c17b76337fd12462e8e",
            "6c7954fdb3b24136944c32a18b008c86",
            "5413a7c0822a4b8ea0c604acd8a5c8a7",
            "22bcc3c6556d475384f917da6be1f4d1",
            "89f37dc4a9bf49eb80cf03cf05677b92",
            "f53a7d252eb743a980ab871a261928ec"
          ]
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:88: UserWarning: \n",
            "The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
            "To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
            "You will be able to reuse this secret in all of your notebooks.\n",
            "Please note that authentication is recommended but still optional to access public models or datasets.\n",
            "  warnings.warn(\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Downloading readme:   0%|          | 0.00/233 [00:00<?, ?B/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "a2c808c03cce4c2bbc9d467b8d519e64"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Downloading data:   0%|          | 0.00/22.5M [00:00<?, ?B/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "f7dc8c26fe89414a9270796103d46fa8"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Generating train split: 0 examples [00:00, ? examples/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "9d19a2d081bd436c811acbc6c7eb7987"
            }
          },
          "metadata": {}
        }
      ],
      "source": [
        "from datasets import load_dataset\n",
        "\n",
        "data = load_dataset(\"keivalya/MedQuad-MedicalQnADataset\", split='train')\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 363
        },
        "id": "JnWZTcJiXzor",
        "outputId": "a8b162f3-32a7-4b02-fd4d-27f928bce98c"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "             qtype                                           Question  \\\n",
              "0   susceptibility  Who is at risk for Lymphocytic Choriomeningiti...   \n",
              "1         symptoms  What are the symptoms of Lymphocytic Choriomen...   \n",
              "2   susceptibility  Who is at risk for Lymphocytic Choriomeningiti...   \n",
              "3  exams and tests  How to diagnose Lymphocytic Choriomeningitis (...   \n",
              "4        treatment  What are the treatments for Lymphocytic Chorio...   \n",
              "5       prevention  How to prevent Lymphocytic Choriomeningitis (L...   \n",
              "6      information          What is (are) Parasites - Cysticercosis ?   \n",
              "7   susceptibility    Who is at risk for Parasites - Cysticercosis? ?   \n",
              "8  exams and tests        How to diagnose Parasites - Cysticercosis ?   \n",
              "9        treatment  What are the treatments for Parasites - Cystic...   \n",
              "\n",
              "                                              Answer  \n",
              "0  LCMV infections can occur after exposure to fr...  \n",
              "1  LCMV is most commonly recognized as causing ne...  \n",
              "2  Individuals of all ages who come into contact ...  \n",
              "3  During the first phase of the disease, the mos...  \n",
              "4  Aseptic meningitis, encephalitis, or meningoen...  \n",
              "5  LCMV infection can be prevented by avoiding co...  \n",
              "6  Cysticercosis is an infection caused by the la...  \n",
              "7  Cysticercosis is an infection caused by the la...  \n",
              "8  If you think that you may have cysticercosis, ...  \n",
              "9  Some people with cysticercosis do not need to ...  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-20f75ed1-96ce-4a2b-95cc-b008339b876d\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>qtype</th>\n",
              "      <th>Question</th>\n",
              "      <th>Answer</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>susceptibility</td>\n",
              "      <td>Who is at risk for Lymphocytic Choriomeningiti...</td>\n",
              "      <td>LCMV infections can occur after exposure to fr...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>symptoms</td>\n",
              "      <td>What are the symptoms of Lymphocytic Choriomen...</td>\n",
              "      <td>LCMV is most commonly recognized as causing ne...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>susceptibility</td>\n",
              "      <td>Who is at risk for Lymphocytic Choriomeningiti...</td>\n",
              "      <td>Individuals of all ages who come into contact ...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>exams and tests</td>\n",
              "      <td>How to diagnose Lymphocytic Choriomeningitis (...</td>\n",
              "      <td>During the first phase of the disease, the mos...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>treatment</td>\n",
              "      <td>What are the treatments for Lymphocytic Chorio...</td>\n",
              "      <td>Aseptic meningitis, encephalitis, or meningoen...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>prevention</td>\n",
              "      <td>How to prevent Lymphocytic Choriomeningitis (L...</td>\n",
              "      <td>LCMV infection can be prevented by avoiding co...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>information</td>\n",
              "      <td>What is (are) Parasites - Cysticercosis ?</td>\n",
              "      <td>Cysticercosis is an infection caused by the la...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>susceptibility</td>\n",
              "      <td>Who is at risk for Parasites - Cysticercosis? ?</td>\n",
              "      <td>Cysticercosis is an infection caused by the la...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>exams and tests</td>\n",
              "      <td>How to diagnose Parasites - Cysticercosis ?</td>\n",
              "      <td>If you think that you may have cysticercosis, ...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>treatment</td>\n",
              "      <td>What are the treatments for Parasites - Cystic...</td>\n",
              "      <td>Some people with cysticercosis do not need to ...</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-20f75ed1-96ce-4a2b-95cc-b008339b876d')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-20f75ed1-96ce-4a2b-95cc-b008339b876d button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-20f75ed1-96ce-4a2b-95cc-b008339b876d');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-2dba0c6f-bab9-4a54-a0f8-f7217439bf5b\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-2dba0c6f-bab9-4a54-a0f8-f7217439bf5b')\"\n",
              "            title=\"Suggest charts\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-2dba0c6f-bab9-4a54-a0f8-f7217439bf5b button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "dataframe",
              "variable_name": "data",
              "summary": "{\n  \"name\": \"data\",\n  \"rows\": 16407,\n  \"fields\": [\n    {\n      \"column\": \"qtype\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 16,\n        \"samples\": [\n          \"susceptibility\",\n          \"symptoms\",\n          \"information\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Question\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 14979,\n        \"samples\": [\n          \"What are the symptoms of Danon disease ?\",\n          \"What is (are) Dowling-Degos disease ?\",\n          \"What are the genetic changes related to Pearson marrow-pancreas syndrome ?\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Answer\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 15817,\n        \"samples\": [\n          \"These resources address the diagnosis or management of glycogen storage disease type III:  - Gene Review: Gene Review: Glycogen Storage Disease Type III  - Genetic Testing Registry: Glycogen storage disease type III   These resources from MedlinePlus offer information about the diagnosis and management of various health conditions:  - Diagnostic Tests  - Drug Therapy  - Surgery and Rehabilitation  - Genetic Counseling   - Palliative Care\",\n          \"Diagnostic Challenges\\n  \\nFor doctors, diagnosing chronic fatigue syndrome (CFS) can be complicated by a number of factors:\\n  \\n   - There's no lab test or biomarker for CFS.\\n   - Fatigue and other symptoms of CFS are common to many illnesses.\\n   - For some CFS patients, it may not be obvious to doctors that they are ill.\\n   - The illness has a pattern of remission and relapse.\\n   - Symptoms vary from person to person in type, number, and severity.\\n  \\n  \\nThese factors have contributed to a low diagnosis rate. Of the one to four million Americans who have CFS, less than 20% have been diagnosed.\\n  Exams and Screening Tests for CFS\\n  \\nBecause there is no blood test, brain scan, or other lab test to diagnose CFS, the doctor should first rule out other possible causes.\\n  \\nIf a patient has had 6 or more consecutive months of severe fatigue that is reported to be unrelieved by sufficient bed rest and that is accompanied by nonspecific symptoms, including flu-like symptoms, generalized pain, and memory problems, the doctor should consider the possibility that the patient may have CFS. Further exams and tests are needed before a diagnosis can be made:\\n  \\n   - A detailed medical history will be needed and should include a review of medications that could be causing the fatigue and symptoms\\n   - A thorough physical and mental status examination will also be needed\\n   - A battery of laboratory screening tests will be needed to help identify or rule out other possible causes of the symptoms that could be treated\\n   - The doctor may also order additional tests to follow up on results of the initial screening tests\\n  \\n  \\nA CFS diagnosis requires that the patient has been fatigued for 6 months or more and has 4 of the 8 symptoms for CFS for 6 months or more. If, however, the patient has been fatigued for 6 months or more but does not have four of the eight symptoms, the diagnosis may be idiopathic fatigue.\\n  \\nThe complete process for diagnosing CFS can be found here.\\n  \\nAdditional information for healthcare professionals on use of tests can be found here.\",\n          \"Eating, diet, and nutrition have not been shown to play a role in causing or preventing simple kidney cysts.\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}"
            }
          },
          "metadata": {},
          "execution_count": 3
        }
      ],
      "source": [
        "data = data.to_pandas()\n",
        "data.head(10)"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#uncoment this line if you want to limit the size of the data.\n",
        "data = data[0:100]"
      ],
      "metadata": {
        "id": "hf7RQa6B5xpx"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "As you can see, the medical information in the dataset is well-organized, and to someone like me, who is not an expert in the field, it appears to be quite valuable. This information could be a useful addition to any general medicine book to support primary care doctors."
      ],
      "metadata": {
        "id": "4FhUslovtiqn"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Load the langchain libraries to load the document."
      ],
      "metadata": {
        "id": "2sLkrHF6lWhM"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from langchain.document_loaders import DataFrameLoader\n",
        "from langchain.vectorstores import Chroma"
      ],
      "metadata": {
        "id": "cCBAlIb596wZ"
      },
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "The Document is in the Answer column, and the others columns are Metadata."
      ],
      "metadata": {
        "id": "nGCkVX6xldOR"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "df_loader = DataFrameLoader(data, page_content_column=\"Answer\")\n"
      ],
      "metadata": {
        "id": "JZX8SaTe99Uf"
      },
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "df_document = df_loader.load()\n",
        "display(df_document[:2])"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 486
        },
        "id": "HDWnTqRY-IDr",
        "outputId": "cc23e79c-881c-4b53-c1dc-e03529cf0b96"
      },
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "[Document(page_content='LCMV infections can occur after exposure to fresh urine, droppings, saliva, or nesting materials from infected rodents.  Transmission may also occur when these materials are directly introduced into broken skin, the nose, the eyes, or the mouth, or presumably, via the bite of an infected rodent. Person-to-person transmission has not been reported, with the exception of vertical transmission from infected mother to fetus, and rarely, through organ transplantation.', metadata={'qtype': 'susceptibility', 'Question': 'Who is at risk for Lymphocytic Choriomeningitis (LCM)? ?'}),\n",
              " Document(page_content='LCMV is most commonly recognized as causing neurological disease, as its name implies, though infection without symptoms or mild febrile illnesses are more common clinical manifestations. \\n                \\nFor infected persons who do become ill, onset of symptoms usually occurs 8-13 days after exposure to the virus as part of a biphasic febrile illness. This initial phase, which may last as long as a week, typically begins with any or all of the following symptoms: fever, malaise, lack of appetite, muscle aches, headache, nausea, and vomiting. Other symptoms appearing less frequently include sore throat, cough, joint pain, chest pain, testicular pain, and parotid (salivary gland) pain. \\n                \\nFollowing a few days of recovery, a second phase of illness may occur. Symptoms may consist of meningitis (fever, headache, stiff neck, etc.), encephalitis (drowsiness, confusion, sensory disturbances, and/or motor abnormalities, such as paralysis), or meningoencephalitis (inflammation of both the brain and meninges). LCMV has also been known to cause acute hydrocephalus (increased fluid on the brain), which often requires surgical shunting to relieve increased intracranial pressure. In rare instances, infection results in myelitis (inflammation of the spinal cord) and presents with symptoms such as muscle weakness, paralysis, or changes in body sensation. An association between LCMV infection and myocarditis (inflammation of the heart muscles) has been suggested. \\n                \\nPrevious observations show that most patients who develop aseptic meningitis or encephalitis due to LCMV survive. No chronic infection has been described in humans, and after the acute phase of illness, the virus is cleared from the body. However, as in all infections of the central nervous system, particularly encephalitis, temporary or permanent neurological damage is possible. Nerve deafness and arthritis have been reported. \\n                \\nWomen who become infected with LCMV during pregnancy may pass the infection on to the fetus. Infections occurring during the first trimester may result in fetal death and pregnancy termination, while in the second and third trimesters, birth defects can develop. Infants infected In utero can have many serious and permanent birth defects, including vision problems, mental retardation, and hydrocephaly (water on the brain). Pregnant women may recall a flu-like illness during pregnancy, or may not recall any illness. \\n                \\nLCM is usually not fatal. In general, mortality is less than 1%.', metadata={'qtype': 'symptoms', 'Question': 'What are the symptoms of Lymphocytic Choriomeningitis (LCM) ?'})]"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We can chunk the documents. The size to which we want to split the document is a design decision. The larger it is, the larger the prompt will be, and the slower the Model's response process.\n",
        "\n",
        "We also need to consider the maximum prompt size and ensure that the document does not exceed it."
      ],
      "metadata": {
        "id": "zPuTbSsXl3uF"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from langchain.text_splitter import CharacterTextSplitter"
      ],
      "metadata": {
        "id": "8wogWV1_-lxh"
      },
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "text_splitter = CharacterTextSplitter(chunk_size=1250,\n",
        "                                      separator=\"\\n\",\n",
        "                                      chunk_overlap=100)\n",
        "texts = text_splitter.split_documents(df_document)\n"
      ],
      "metadata": {
        "id": "kg7SRkqO-f9x",
        "outputId": "d103257d-b0be-480c-b6ff-06339086f86f",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "WARNING:langchain.text_splitter:Created a chunk of size 2198, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1402, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1970, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1260, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1483, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1346, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1342, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1504, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2257, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1669, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3068, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2160, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1826, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1293, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2184, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2266, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1609, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1748, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4826, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1357, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3599, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1639, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1427, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3348, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1257, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1993, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1860, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2392, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1356, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1356, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1934, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1576, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3021, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1296, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1593, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1399, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2365, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1303, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1917, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1422, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1441, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1441, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1534, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2725, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2738, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2239, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1885, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1285, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1574, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1889, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1343, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3179, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1259, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3622, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3477, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2723, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3057, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2017, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1881, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1426, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1364, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2879, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3643, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2781, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1262, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1871, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1880, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2342, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2544, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2329, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3275, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1280, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3075, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1574, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2054, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3041, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3142, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3403, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1456, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3304, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3298, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1285, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4052, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3306, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2690, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 6374, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2285, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3087, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3866, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1969, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1917, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1972, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1758, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4553, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1738, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3175, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1738, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3175, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1568, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2298, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1568, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1551, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5112, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5016, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2724, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2087, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1812, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2346, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4966, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1385, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1740, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3100, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1333, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1577, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2467, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1409, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4153, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1445, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1353, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2019, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1567, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5319, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2266, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1958, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1935, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1493, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1326, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3083, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1294, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1493, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2002, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2773, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1786, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 6207, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1795, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1768, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2180, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1686, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4948, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3020, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1396, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1814, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4077, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2222, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2942, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1604, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1659, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1352, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1604, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1352, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4836, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1408, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4836, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1408, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3636, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4637, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2286, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1577, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2286, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1577, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2384, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1324, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3858, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1324, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1459, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 6322, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1720, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4121, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2637, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5511, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1498, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2789, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5638, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1391, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1706, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1706, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1362, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5050, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2258, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1288, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2497, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1661, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 6859, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4307, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4111, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2430, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 7764, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1790, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2267, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1314, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1790, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2267, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1424, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1427, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2373, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5871, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1276, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1696, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3100, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1682, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2878, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3133, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2507, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2949, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 7390, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5780, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2080, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1700, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4007, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1403, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4007, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1515, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1540, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2263, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1867, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4754, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2199, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1452, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1737, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1517, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1355, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1780, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2879, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3302, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1747, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2534, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1597, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3547, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1442, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1693, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2181, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2390, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3035, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1845, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3094, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5256, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1543, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1433, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1497, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1659, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1358, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3066, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5713, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2003, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1337, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2433, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2424, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3990, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1337, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1426, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2502, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3287, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2560, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1485, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1528, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2390, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1417, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3997, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 6157, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1417, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3997, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 6157, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2004, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2450, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4308, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 11355, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5110, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2230, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1542, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2346, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2786, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2760, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1539, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3383, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1472, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1901, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1515, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1984, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 8754, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 13272, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1346, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1539, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3343, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5719, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 6570, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3343, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2792, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3437, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2144, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 7391, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1488, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1782, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1307, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3700, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1338, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1558, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3530, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2075, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4895, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1317, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1337, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1811, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5861, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1761, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2862, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1761, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2128, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3456, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1334, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1549, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3179, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2775, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3602, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4131, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1817, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2168, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1817, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1337, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3273, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2855, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1716, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2968, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1716, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4750, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1500, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2601, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3589, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1700, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2412, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2365, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2899, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1566, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2915, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1665, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2528, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1273, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1561, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4090, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 5312, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1702, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4174, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3655, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2479, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1475, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2416, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1967, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2625, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1475, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3127, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4071, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4884, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1916, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2141, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3359, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2524, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1296, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 3817, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4163, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 8529, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2628, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1547, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2081, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2345, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 4652, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1366, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1371, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1367, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1725, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2579, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2285, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2285, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1659, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1741, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 7840, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2211, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 1544, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 2923, which is longer than the specified 1250\n",
            "WARNING:langchain.text_splitter:Created a chunk of size 9280, which is longer than the specified 1250\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "These warnings we see are because it can't perform the partition of the required size. This is because it waits for a page break to divide the text and does so when possible."
      ],
      "metadata": {
        "id": "y0dn9EfrKoeW"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "first_doc = texts[1]\n",
        "print(first_doc.page_content)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "XaLWV_TzASSB",
        "outputId": "f9cf8138-6cfe-46d7-cc5e-26de1b822e12"
      },
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "LCMV is most commonly recognized as causing neurological disease, as its name implies, though infection without symptoms or mild febrile illnesses are more common clinical manifestations. \n",
            "                \n",
            "For infected persons who do become ill, onset of symptoms usually occurs 8-13 days after exposure to the virus as part of a biphasic febrile illness. This initial phase, which may last as long as a week, typically begins with any or all of the following symptoms: fever, malaise, lack of appetite, muscle aches, headache, nausea, and vomiting. Other symptoms appearing less frequently include sore throat, cough, joint pain, chest pain, testicular pain, and parotid (salivary gland) pain.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "B2_Pt7N6Zg2X"
      },
      "source": [
        "### Initialize the Embedding Model and Vector DB"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We load the text-embedding-ada-002 model from OpenAI."
      ],
      "metadata": {
        "id": "n8ROb8oMnRLD"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from getpass import getpass\n",
        "import os\n",
        "if not 'OPENAI_API_KEY' in os.environ:\n",
        "  os.environ[\"OPENAI_API_KEY\"] = getpass(\"OpenAI API Key: \")"
      ],
      "metadata": {
        "id": "F_Dn06xGwjKP",
        "outputId": "bd8890e2-8b6e-4ec5-a3a3-e6ec462457ae",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 10,
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "OpenAI API Key: ··········\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Obtain Your LangChain API Key from your Personal->Settings Area in LangSmith panel.\n",
        "\n",
        "![My Image](https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/langsmith_API_KEY.jpg?raw=true)"
      ],
      "metadata": {
        "id": "9NmsRgJ8rPoA"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "if not 'LANGCHAIN_API_KEY' in os.environ:\n",
        "  os.environ[\"LANGCHAIN_API_KEY\"] = getpass(\"LangChain API Key: \")"
      ],
      "metadata": {
        "id": "xjuVU5rIrSRl",
        "outputId": "b438621c-9a1f-44d0-8d52-380046ed9b7a",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 11,
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "LangChain API Key: ··········\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
        "os.environ[\"LANGCHAIN_ENDPOINT\"]=\"https://api.smith.langchain.com\"\n",
        "os.environ[\"LANGCHAIN_PROJECT\"]=\"langsmith_test2\""
      ],
      "metadata": {
        "id": "jjZjm0JmrVsY"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "id": "U57x2_87YSpb"
      },
      "outputs": [],
      "source": [
        "from langchain_openai import OpenAIEmbeddings\n",
        "\n",
        "model_name = 'text-embedding-ada-002'\n",
        "\n",
        "embed = OpenAIEmbeddings(\n",
        "    model=model_name,\n",
        "    #openai_api_key=OPENAI_API_KEY\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "The execution of this cell may take 3 to 5 minutes. If you want it to be faster, you can reduce the number of records in the dataset."
      ],
      "metadata": {
        "id": "cgTCwF7UMyNW"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "directory_cdb = '/content/drive/MyDrive/chromadb'\n",
        "chroma_db = Chroma.from_documents(\n",
        "    df_document, embed, persist_directory=directory_cdb\n",
        ")"
      ],
      "metadata": {
        "id": "SEhQMQ8eCMj8"
      },
      "execution_count": 13,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "We are going to create three objects.\n",
        "\n",
        "* The language model, which can be any of those from OpenAI, the most common being gpt-3.5.\n",
        "* The memory, responsible for keeping the prompt with all the necessary history.\n",
        "* The retrieval, used to obtain information stored in ChromaDB."
      ],
      "metadata": {
        "id": "KhjV-T8GoarF"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 14,
      "metadata": {
        "id": "zMRs9Klic5-Y"
      },
      "outputs": [],
      "source": [
        "from langchain.chat_models import ChatOpenAI\n",
        "from langchain_openai import OpenAI\n",
        "from langchain.chains.conversation.memory import ConversationBufferWindowMemory\n",
        "from langchain.chains import RetrievalQA\n",
        "\n",
        "llm=OpenAI(#openai_api_key=OPENAI_API_KEY,\n",
        "           temperature=0.0)\n",
        "\n",
        "conversational_memory = ConversationBufferWindowMemory(\n",
        "    memory_key='chat_history',\n",
        "    k=4, #Number of messages stored in memory\n",
        "    return_messages=True #Must return the messages in the response.\n",
        ")\n",
        "\n",
        "qa = RetrievalQA.from_chain_type(\n",
        "    llm=llm,\n",
        "    chain_type=\"stuff\",\n",
        "    retriever=chroma_db.as_retriever()\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We can try the isolated Retrieval to see if the information it returns is relevant.\n",
        "\n",
        "\n"
      ],
      "metadata": {
        "id": "ergrieE4o8qu"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 107
        },
        "id": "LaYSq0V-dxHw",
        "outputId": "5bea2c64-8b23-45d7-e136-70cf67c68f3f"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function `run` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n",
            "  warn_deprecated(\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "' The main symptom of Lethal congenital contracture syndrome 1 (LCM) is skeletal muscle atrophy, which is seen in approximately 90% of patients with this condition.'"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "string"
            }
          },
          "metadata": {},
          "execution_count": 15
        }
      ],
      "source": [
        "qa.run(\"What is the main symptom of LCM?\")"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "When observing the Retriever on Langsmith is possible to see the input and the documents returned by it:\n",
        "![My Image](https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/Martra_Figure_4_Retriever_1.jpg?raw=true)\n",
        "\n",
        "In the image below you can observe the call to the Model where the full prompt and the response are displayed.\n",
        "![My Image](https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/Martra_Figure_4_Retriever_2.jpg?raw=true)\n",
        "\n",
        "\n",
        "## Creating the Agent."
      ],
      "metadata": {
        "id": "pf9MXPeipEBO"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 16,
      "metadata": {
        "id": "FwCYrS4duqBW"
      },
      "outputs": [],
      "source": [
        "from langchain.agents import Tool\n",
        "\n",
        "#Defining the list of tool objects to be used by LangChain.\n",
        "tools = [\n",
        "    Tool(\n",
        "        name='Medical KB',\n",
        "        func=qa.run,\n",
        "        description=(\n",
        "            \"\"\"use this tool when answering medical knowledge queries to get\n",
        "            more information about the topic\"\"\"\n",
        "        )\n",
        "    )\n",
        "]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "metadata": {
        "id": "JaKTzPUEvOoy"
      },
      "outputs": [],
      "source": [
        "from langchain.agents import create_react_agent\n",
        "from langchain import hub\n",
        "\n",
        "prompt = hub.pull(\"hwchase17/react-chat\")\n",
        "agent = create_react_agent(\n",
        "    tools=tools,\n",
        "    llm=llm,\n",
        "    prompt=prompt,\n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Create an agent executor by passing in the agent and tools\n",
        "from langchain.agents import AgentExecutor\n",
        "agent_executor2 = AgentExecutor(agent=agent,\n",
        "                               tools=tools,\n",
        "                               verbose=True,\n",
        "                               memory=conversational_memory,\n",
        "                               max_iterations=30,\n",
        "                               max_execution_time=600,\n",
        "                               handle_parsing_errors=True\n",
        "                               )"
      ],
      "metadata": {
        "id": "5sjTL1EU1vNW"
      },
      "execution_count": 18,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "IlxUBWKcvzeP"
      },
      "source": [
        "### Using the Conversational Agent"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ZZapCP4Pv2kz"
      },
      "source": [
        "To make queries we simply call the `agent` directly.\n",
        "\n",
        "First i will try a request not related to the Medical field."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 19,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "85vipqC02deV",
        "outputId": "978491bf-0bb0-41ff-d06a-87e199c199af"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "\n",
            "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
            "\u001b[32;1m\u001b[1;3mThought: Do I need to use a tool? No\n",
            "Final Answer: 4\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "{'input': 'What is 2 multiplied by 2?', 'chat_history': [], 'output': '4'}"
            ]
          },
          "metadata": {},
          "execution_count": 19
        }
      ],
      "source": [
        "agent_executor2.invoke({\"input\": \"What is 2 multiplied by 2?\"})"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "The initial call to the Agent happens with just one call to OpenAI. One piece of information available in LangSmith is the entire prompt. I'll copy it just below the image, so you can see.\n",
        "\n",
        "![My Image](https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/Martra_Figure_4_1AE_1.jpg?raw=true)\n"
      ],
      "metadata": {
        "id": "LaTqyvBgG_wr"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "\n",
        "```\n",
        "Assistant is a large language model trained by OpenAI.\n",
        "\n",
        "Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n",
        "\n",
        "Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n",
        "\n",
        "Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n",
        "\n",
        "TOOLS:\n",
        "------\n",
        "\n",
        "Assistant has access to the following tools:\n",
        "\n",
        "Medical KB: use this tool when answering medical knowledge queries to get\n",
        "            more information about the topic\n",
        "\n",
        "To use a tool, please use the following format:\n",
        "\n",
        "\n",
        "Thought: Do I need to use a tool? Yes\n",
        "Action: the action to take, should be one of [Medical KB]\n",
        "Action Input: the input to the action\n",
        "Observation: the result of the action\n",
        "\n",
        "\n",
        "When you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format:\n",
        "\n",
        "\n",
        "Thought: Do I need to use a tool? No\n",
        "Final Answer: [your response here]\n",
        "\n",
        "\n",
        "Begin!\n",
        "\n",
        "Previous conversation history:\n",
        "[]\n",
        "\n",
        "New input: What is 2 multiplied by 2?\n",
        "```"
      ],
      "metadata": {
        "id": "7LpYqjJuFKlw"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Perfect, the model has responded without accessing the configured knowledge database.\n",
        "\n",
        "Now I will try with a question that is also not related to health."
      ],
      "metadata": {
        "id": "8suStMR7G11e"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "agent_executor2.memory.clear()"
      ],
      "metadata": {
        "id": "Wtwgfuy158LV"
      },
      "execution_count": 20,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": 21,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "RJoAhy76vzAB",
        "outputId": "42c527d9-53c9-4bc5-de5d-4ee3dcd66b07"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "\n",
            "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
            "\u001b[32;1m\u001b[1;3m\n",
            "Thought: Do I need to use a tool? Yes\n",
            "Action: Medical KB\n",
            "Action Input: Botulism\u001b[0m\u001b[36;1m\u001b[1;3m Botulism is a rare but serious illness caused by a toxin produced by the bacterium Clostridium botulinum. It can occur in several forms, including foodborne, wound, and infant botulism. Symptoms include double or blurred vision, drooping eyelids, slurred speech, difficulty swallowing, dry mouth, and muscle weakness. It is considered a medical emergency and can be fatal if left untreated. To prevent botulism, it is important to be careful when canning foods at home, not let babies eat honey, and seek prompt medical care for infected wounds.\u001b[0m\u001b[32;1m\u001b[1;3mDo I need to use a tool? No\n",
            "Final Answer: To confirm the diagnosis of botulism, a doctor may perform a physical exam, review symptoms, and order laboratory tests. These tests may include a stool or blood test to detect the toxin, a nerve conduction test to check for muscle weakness, and an electromyography (EMG) to measure the electrical activity of muscles. It is important to seek medical attention immediately if botulism is suspected.\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "{'input': 'I have a patient that can have Botulism,\\nhow can I confirm the diagnosis?',\n",
              " 'chat_history': [],\n",
              " 'output': 'To confirm the diagnosis of botulism, a doctor may perform a physical exam, review symptoms, and order laboratory tests. These tests may include a stool or blood test to detect the toxin, a nerve conduction test to check for muscle weakness, and an electromyography (EMG) to measure the electrical activity of muscles. It is important to seek medical attention immediately if botulism is suspected.'}"
            ]
          },
          "metadata": {},
          "execution_count": 21
        }
      ],
      "source": [
        "agent_executor2.invoke({\"input\": \"\"\"I have a patient that can have Botulism,\n",
        "how can I confirm the diagnosis?\"\"\"})"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Perfect, the most important thing for us is that it has been able to identify that it should go to the medical database to search for information about the symptoms.\n",
        "![My Image](https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/Martra_Figure_4_1AE_3.jpg?raw=true)"
      ],
      "metadata": {
        "id": "8lsaoF8nJNnR"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 22,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "mQeicHTj2pmY",
        "outputId": "5044ea2d-4dae-4798-e7b7-1b39074ed039"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "\n",
            "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
            "\u001b[32;1m\u001b[1;3m\n",
            "Thought: Do I need to use a tool? No\n",
            "Final Answer: Yes, botulism is a serious illness that can lead to paralysis and even death if left untreated. It is important to seek medical attention immediately if botulism is suspected.\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "{'input': 'Is this an important illness?',\n",
              " 'chat_history': [HumanMessage(content='I have a patient that can have Botulism,\\nhow can I confirm the diagnosis?'),\n",
              "  AIMessage(content='To confirm the diagnosis of botulism, a doctor may perform a physical exam, review symptoms, and order laboratory tests. These tests may include a stool or blood test to detect the toxin, a nerve conduction test to check for muscle weakness, and an electromyography (EMG) to measure the electrical activity of muscles. It is important to seek medical attention immediately if botulism is suspected.')],\n",
              " 'output': 'Yes, botulism is a serious illness that can lead to paralysis and even death if left untreated. It is important to seek medical attention immediately if botulism is suspected.'}"
            ]
          },
          "metadata": {},
          "execution_count": 22
        }
      ],
      "source": [
        "agent_executor2.invoke({\"input\": \"Is this an important illness?\"})"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "On the left side of the image, you can see the various calls made by the Agent, which took 2.5 seconds to execute and consumed 2000 tokens.\n",
        "\n",
        "I will try to describe what happens in each call.\n",
        "\n",
        "**OpenAI**: he complete prompt, including the template from Hugging Face, and the user's question is passed to the OpenAI Model. It responds with the following step. Its answer is:\n",
        "\n",
        "*Thought: Do I need to use a tool?*\n",
        "\n",
        "*Yes  Action: Medical KB*  \n",
        "\n",
        "*Action Input: Botulism*\n",
        "\n",
        "**Medical KB**: The Agent utilizes the configured tool, passing only a single word as a parameter: \"Botulism.\"\n",
        "\n",
        "**Medical KB.Retriever:** The retriever returns four documents extracted from the Vectorial Database.\n",
        "\n",
        "**Medical KB.OpenAI:** The prompt is constructed with the information from the vectorial database. Even though I won't include the paste, I manage to identify that the four returned documents are actually two but duplicated. This, in a real project, could have helped me detect some issue, perhaps I have duplicates in the dataset, or maybe I loaded them twice. In any case, I'm consuming many more tokens than necessary. The model returns a response created considering the information contained in the prompt.\n",
        "\n",
        "**OpenAI:** In this final call to the model, it decides that the received response is what the user needs. Therefore, it marks it as correct and returns it to the user.\n",
        "\n",
        "![My Image](https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/Martra_Figure_4_1AE_3.jpg?raw=true)"
      ],
      "metadata": {
        "id": "_uNIh-zXKefJ"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "And the memory works perfectly. We can maintain a conversation, taking into account that the model knows the previous questions and answers.\n",
        "\n",
        "\n",
        "# Conclusions.\n",
        "LangSmith is an incredibly useful tool for tracing and storing all the information generated when making calls to LangChain.\n",
        "\n",
        "The experiment has been a small success. The Vectorial database has been configured and filled with information from the dataset. A LangChain agent has been created, and it has been able to retrieve information from the database only when necessary. Don't forget that our ChatBot has memory.\n",
        "\n",
        "\n",
        "\n",
        "And you have all the information in a project stored in LangSmith!!!!\n",
        "![My Image](https://github.com/peremartra/Large-Language-Model-Notebooks-Course/blob/main/img/Martra_Figure_4_1AE_Final.jpg?raw=true)\n",
        "\n"
      ],
      "metadata": {
        "id": "gdyhyd6nJnwN"
      }
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Ykg5TYA033yR"
      },
      "source": [
        "---"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": [],
      "machine_shape": "hm",
      "gpuType": "V100",
      "include_colab_link": true
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.9.12"
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "a2c808c03cce4c2bbc9d467b8d519e64": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_748378a5112f4762a1369cca9d77cf20",
              "IPY_MODEL_4361d59ef82f43ca90184953d81edccb",
              "IPY_MODEL_efb885302da14b20bc2d0477c839eeea"
            ],
            "layout": "IPY_MODEL_b19d4fcd66874a2294c70ac0d7e39886"
          }
        },
        "748378a5112f4762a1369cca9d77cf20": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_38a7b565d9cb4ef0b919656e38ff5aff",
            "placeholder": "​",
            "style": "IPY_MODEL_03be5a89a311430cab159456967206f9",
            "value": "Downloading readme: 100%"
          }
        },
        "4361d59ef82f43ca90184953d81edccb": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_b871473561b94294b833a7a9018f0e0e",
            "max": 233,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_9ffcd6a598a04af1916ed206b7e7ad9d",
            "value": 233
          }
        },
        "efb885302da14b20bc2d0477c839eeea": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_76f88769f6de400ebbc61fbd902900aa",
            "placeholder": "​",
            "style": "IPY_MODEL_79220cfaa4f8446e968bf27f5100b8a5",
            "value": " 233/233 [00:00&lt;00:00, 16.1kB/s]"
          }
        },
        "b19d4fcd66874a2294c70ac0d7e39886": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "38a7b565d9cb4ef0b919656e38ff5aff": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "03be5a89a311430cab159456967206f9": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "b871473561b94294b833a7a9018f0e0e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "9ffcd6a598a04af1916ed206b7e7ad9d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "76f88769f6de400ebbc61fbd902900aa": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "79220cfaa4f8446e968bf27f5100b8a5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "f7dc8c26fe89414a9270796103d46fa8": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_3e72acf13fd94e14bafcfd59e66a94f0",
              "IPY_MODEL_36bc7364f6094102b8c9c03ea183fb7d",
              "IPY_MODEL_8d243a889a484d43b46ef166987461b1"
            ],
            "layout": "IPY_MODEL_7b44788fa5ca429faa283b1a2cd2a194"
          }
        },
        "3e72acf13fd94e14bafcfd59e66a94f0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_8c9d6fe25d2c4a00a4ca561c8568abc0",
            "placeholder": "​",
            "style": "IPY_MODEL_1b1c33a2a5a348a98fd06644a4d5cb28",
            "value": "Downloading data: 100%"
          }
        },
        "36bc7364f6094102b8c9c03ea183fb7d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_869ed7f3b5e94da29bd8e78b92bcf2e8",
            "max": 22466890,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_4bdea684772845cfb4a865f291014895",
            "value": 22466890
          }
        },
        "8d243a889a484d43b46ef166987461b1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_10bf5a0da37b4a58916fa88b30fef35e",
            "placeholder": "​",
            "style": "IPY_MODEL_3828bb2edc5648e1b05077c6b908f025",
            "value": " 22.5M/22.5M [00:00&lt;00:00, 25.3MB/s]"
          }
        },
        "7b44788fa5ca429faa283b1a2cd2a194": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "8c9d6fe25d2c4a00a4ca561c8568abc0": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "1b1c33a2a5a348a98fd06644a4d5cb28": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "869ed7f3b5e94da29bd8e78b92bcf2e8": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "4bdea684772845cfb4a865f291014895": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "10bf5a0da37b4a58916fa88b30fef35e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "3828bb2edc5648e1b05077c6b908f025": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "9d19a2d081bd436c811acbc6c7eb7987": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_7063a9f5b96e4f59b5510f0f05486587",
              "IPY_MODEL_017948bf45934498b33caa4854db2836",
              "IPY_MODEL_e932d3d124184cc7b94f2a2da1ac1920"
            ],
            "layout": "IPY_MODEL_d409bfdff1de4947b9ede61d37d9f08e"
          }
        },
        "7063a9f5b96e4f59b5510f0f05486587": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_a951c64095ff4c17b76337fd12462e8e",
            "placeholder": "​",
            "style": "IPY_MODEL_6c7954fdb3b24136944c32a18b008c86",
            "value": "Generating train split: "
          }
        },
        "017948bf45934498b33caa4854db2836": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_5413a7c0822a4b8ea0c604acd8a5c8a7",
            "max": 1,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_22bcc3c6556d475384f917da6be1f4d1",
            "value": 1
          }
        },
        "e932d3d124184cc7b94f2a2da1ac1920": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_89f37dc4a9bf49eb80cf03cf05677b92",
            "placeholder": "​",
            "style": "IPY_MODEL_f53a7d252eb743a980ab871a261928ec",
            "value": " 16407/0 [00:00&lt;00:00, 38702.03 examples/s]"
          }
        },
        "d409bfdff1de4947b9ede61d37d9f08e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "a951c64095ff4c17b76337fd12462e8e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "6c7954fdb3b24136944c32a18b008c86": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "5413a7c0822a4b8ea0c604acd8a5c8a7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": "20px"
          }
        },
        "22bcc3c6556d475384f917da6be1f4d1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "89f37dc4a9bf49eb80cf03cf05677b92": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f53a7d252eb743a980ab871a261928ec": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        }
      }
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}